<%@page import="com.easyattendance.services.AddSubjectService"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
 <%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Iterator" %>
<%@ page import ="com.easyattendance.services.AddTeacherService" %>
<%@ page import ="com.easyattendance.model.Teacher" %>
<%@ page import ="com.easyattendance.services.AddClassService" %>
<%@ page import ="com.easyattendance.model.Class" %>
<%@ page import ="com.easyattendance.services.AddTeacherService" %>
<%@ page import ="com.easyattendance.model.Teacher" %>
<%@ page import ="com.easyattendance.model.Subject" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Add Students for Elective Subjects</title>
<!-- <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> -->
<jsp:include page="../includeFiles.jsp" />

<body class="left-sidebar" onload="getValues()">

<!-- Session check : user logged in or not/ press back button -->
<jsp:include page="../common/checkSession.jsp"></jsp:include>
<jsp:include page="../common/checkTeacherRole.jsp" />

<% String currentUser = (String) session.getAttribute("currentUser"); 
	AddClassService addClassService = new AddClassService();
	Class tempClass = addClassService.getClassById(addClassService.getClassIdByTeacherId(currentUser));
	AddSubjectService addSubjectService = new AddSubjectService();
	List electiveTypes = addSubjectService.listElectiveTypesByClassId(tempClass.getClass_id());
%>
	
	<!-- Wrapper -->
	<div id="wrapper">

		<!-- Content -->
		<div id="content">
			<div id="content-inner">

				
						<TABLE name="addStudElective" id="tbl_student_subject" border=2>
			
							<TR>
								<TH> Choose Elective Type:
									<select tabindex="1" name="elective_select" id="elective_select">
									<option value="">Choose Elective Type
										<% Iterator iterator = electiveTypes.iterator();
											while(iterator.hasNext()) {
												String elective = (String)iterator.next();
											%>
													<option value=<%=elective%>><%=elective%>
												<% } %>
									</select>
								</TH>
							</TR>
							<TR>
								<TH>Student Roll No</TH>
								<TH>Student Name</TH>
								<TH>Present</TH>
								<TH>Absent</TH>
								<TH>Remarks</TH>
							</TR>
						
								<%-- <% for(int i = 0; i < studList.size(); i++) { %> --%>
							<TR>
					
								<TD>
								<!--  put labels instead of text IF v are not going to change in the student name and ID -->
									<input type="text" name="stud_id" value="" id="stud_id" readonly="readonly"/>
								
								</TD>
								<TD>
									<input type="text" name="stud_name" value="" id="stud_name" readonly="readonly"/>
								</TD>
								
								<TD><input type="radio" name="status" id="present" value="present"/> </TD>
								<TD><input type="radio" name="status" id="absent" value="absent"/></TD>
								<TD><input type="radio" name="status" id="absent_eith_leave" value="absent with leave"/></TD>
							</TR>					
					</TABLE>
						
							<div>	
								<input type="submit" value="Submit Attendance" class="button">
								<input type="submit" value="Edit" class="button" disabled="disabled" action="editAttendance.jsp">
							</div>
							
			</div>
		</div>

		<!-- Sidebar -->
		<div id="sidebar">

			<!-- Sidebar Header - Logo & Name -->
			<jsp:include page="../common/sidebarHeader.jsp" />

			<jsp:include page="teacherMenu.jsp" />

			<!-- Sidebar Footer Content -->
			<jsp:include page="../common/sidebarFooter.jsp" />

		</div>

	</div>	
	<script type="text/javascript">
		$(function(){
			$("#selectStudentElectives").addClass("current_page_item");
		});
		var contextPath='<%=request.getContextPath()%>';
	</script>
	
	<!--  For drop down values -->
	<script type="text/javascript">
	
		
	$("#elective_select").change(function() {
		var elective = $("#elective_select").val();
		//$('#time_slot').attr("value", timeslot);
		setCookie("elective_select",elective);
		//console.log(elective);
		window.location.replace(contextPath + "/views/teacher/addStudentElectiveSubject.jsp?elective=" + elective);

	});
		
		function setCookie(name, value) {
			  var today = new Date(); 
			  var expiry = new Date(today.getTime() + 1 * 24 * 3600 * 1000); // plus 30 days
			  document.cookie=name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString();
			  //console.log("set cook");
		 }
			 
		function getCookie(name) { 
			var re = new RegExp(name + "=([^;]+)"); 
			var value = re.exec(document.cookie);
			console.log("get cook");
			return (value != null) ? unescape(value[1]) : null; 
		}
		
		function deleteCookie(name)
		{
			var expired = new Date(today.getTime() - 24 * 3600 * 1000); // less 24 hours
			document.cookie=name + "=null; path=/; expires=" + expired.toGMTString();
		}
		
		function getValues(){
			$("#elective_select").val(getCookie("elective_select"));
		}
		
		function clearCookie(){
			deleteCookie("elective_select");
		}

		
	</script>
	
	</body>
</html>